﻿#region Using

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

#endregion // Using

namespace QbservableCore.Serialization.Helpers
{
    /// <summary>
    /// Lightweight representation of the System.Type (solve generics serialization issues)
    /// </summary>
    [DataContract]
    [Obsolete]
    public class LightweightSerializableType
    {
        [DataMember]
        public string _fullyQualifiedTypeName { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="LightweightSerializableType" /> class.
        /// </summary>
        /// <param name="type">The type for serialization</param>
        public LightweightSerializableType(Type type)
        {
            if (type != null)
            {
                _fullyQualifiedTypeName = type.AssemblyQualifiedName;
            }
        }

        /// <summary>
        /// Using reflection to receive the original type
        /// </summary>
        /// <returns></returns>
        public Type ToType()
        {
            Type t = Type.GetType(_fullyQualifiedTypeName);
            return t;
        }
    }
}